home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / daemons / ipServer / tcpTimer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-16  |  4.9 KB  |  131 lines

  1. /*
  2.  * tcpTimer.h --
  3.  *
  4.  *    Definitions of timers for the TCP protocol.
  5.  *
  6.  *    Based on 4.3BSD @(#)tcp_timer.h    7.5 (Berkeley) 3/16/88
  7.  *
  8.  * Copyright 1987 Regents of the University of California
  9.  * All rights reserved.
  10.  * Permission to use, copy, modify, and distribute this
  11.  * software and its documentation for any purpose and without
  12.  * fee is hereby granted, provided that the above copyright
  13.  * notice appear in all copies.  The University of California
  14.  * makes no representations about the suitability of this
  15.  * software for any purpose.  It is provided "as is" without
  16.  * express or implied warranty.
  17.  *
  18.  * $Header: /sprite/src/daemons/ipServer/RCS/tcpTimer.h,v 1.5 89/08/15 19:55:52 rab Exp $ SPRITE (Berkeley)
  19.  */
  20.  
  21. #ifndef _IPS_TCP_TIMER
  22. #define _IPS_TCP_TIMER
  23. /*
  24.  * Definitions of the 4 TCP timers:
  25.  *
  26.  * The TCP_TIMER_REXMT timer is used to force retransmissions.  The TCB
  27.  * has the TCP_TIMER_REXMT timer set whenever segments have been sent for
  28.  * which ACKs are expected but not yet received.  If an ACK is received
  29.  * that advances tcbPtr->send.unAck, then the retransmit timer is cleared (if
  30.  * there are no more outstanding segments) or reset to the base value (if
  31.  * more ACKs are expected).  Whenever the retransmit timer goes off,
  32.  * we retransmit one unacknowledged segment, and do a backoff on the
  33.  * retransmit timer.
  34.  *
  35.  * The TCP_TIMER_PERSIST timer is used to keep window size information
  36.  * flowing even if the window goes shut.  If all previous transmissions
  37.  * have been acknowledged (so that there are no retransmissions in
  38.  * progress), and the window is too small to bother sending anything, then
  39.  * we start the TCP_TIMER_PERSIST timer.  When it expires, if the window
  40.  * is nonzero, we go into the transmit state.  Otherwise, at intervals, send a
  41.  * single byte into the peer's window to force him to update our window
  42.  * information.  We do this at most as TCP_MIN_PERSIST_TIME time
  43.  * intervals, but no more frequently than the current estimate of
  44.  * round-trip packet time.  The TCP_TIMER_PERSIST timer is cleared
  45.  * whenever we receive a window update from the peer.
  46.  *
  47.  * The TCP_TIMER_KEEP_ALIVE timer is used to keep connections alive.  If a
  48.  * connection is idle (no segments received) for TCP_KEEP_TIME_INIT amount
  49.  * of time, but not yet established, then we drop the connection.  Once
  50.  * the connection is established, if the connection is idle for
  51.  * TCP_KEEP_TIMER_IDLE time (and keepalives have been enabled on the
  52.  * socket), we begin to probe the connection.  We force the peer to send
  53.  * us a segment by sending:
  54.  *      <SEQ=SEND.UNACK-1><ACK=RECV.NEXT><CTL=ACK>
  55.  * This segment is (deliberately) outside the window, and should elicit an
  56.  * ack segment in response from the peer.  If, despite the
  57.  * TCP_TIMER_KEEP_ALIVE initiated segments we cannot elicit a response
  58.  * from a peer after TCP_KEEP_COUNT times, then we drop the connection.
  59.  */
  60.  
  61. #define    TCP_NUM_TIMERS        4
  62.  
  63. #define    TCP_TIMER_REXMT        0        /* retransmit */
  64. #define    TCP_TIMER_PERSIST    1        /* retransmit persistence */
  65. #define    TCP_TIMER_KEEP_ALIVE    2        /* keep alive */
  66. #define    TCP_TIMER_2MSL        3        /* 2*msl quiet time timer */
  67.  
  68. #ifdef    TCP_TIMER_NAMES
  69. char *tcpTimers[] =
  70.     { "REXMT", "PERSIST", "KEEP ALIVE", "2MSL" };
  71. #endif
  72.  
  73. /*
  74.  * Number of times per second to update timers.
  75.  */
  76.  
  77. #define    TIMER_UPDATE_RATE    2
  78. /*
  79.  * Time constants: (In timer ticks)
  80.  *
  81.  * TCP_MSL_TIME        - maximum segment lifetime.
  82.  * TCP_SRTT_BASE_TIME    - base roundtrip time; if 0, no idea yet.
  83.  * TCP_SRTT_DEFLT_TIME    - assumed RTT if no info.
  84.  * TCP_KEEP_TIME_INIT    - initial connect keep-alive time.
  85.  * TCP_KEEP_TIME_IDLE    - default time before probing.
  86.  * TCP_KEEP_TIME_INTVL    - default proble interval.
  87.  * TCP_MIN_PERSIST_TIME    - retransmit persistence.
  88.  * TCP_MAX_PERSIST_TIME    - maximum retransmit persistence.
  89.  * TCP_MIN_REXMT_TIME    - minimum allowable value for retransmit timer.
  90.  * TCP_MAX_REXMT_TIME    - maximum allowable value for retrans. and persist
  91.  *              timers.
  92.  *
  93.  * Other constants:
  94.  * TCP_MAX_RXT_SHIFT    - maximum number of retransmissions.
  95.  * TCP_KEEP_COUNT    - max. # of probes before we drop the connection.
  96.  */
  97.  
  98. #define    TCP_MSL_TIME        (30 * TIMER_UPDATE_RATE)
  99. #define    TCP_SRTT_BASE_TIME     (0 * TIMER_UPDATE_RATE)
  100. #define    TCP_SRTT_DEFLT_TIME     (3 * TIMER_UPDATE_RATE)
  101.  
  102. #define    TCP_KEEP_TIME_INIT    (75 * TIMER_UPDATE_RATE)
  103. #define    TCP_KEEP_TIME_IDLE    ((120*60) * TIMER_UPDATE_RATE)
  104. #define    TCP_KEEP_TIME_INTVL    (75 * TIMER_UPDATE_RATE)
  105.  
  106. #define    TCP_MIN_PERSIST_TIME     (5* TIMER_UPDATE_RATE)
  107. #define    TCP_MAX_PERSIST_TIME    (60 * TIMER_UPDATE_RATE)
  108.  
  109. #define    TCP_MIN_REXMT_TIME    ( 1 * TIMER_UPDATE_RATE)
  110. #define    TCP_MAX_REXMT_TIME    (64 * TIMER_UPDATE_RATE)
  111.  
  112. #define    TCP_KEEP_COUNT         8
  113. #define    TCP_MAX_RXT_SHIFT    12
  114.  
  115. extern int tcpKeepIdle;
  116. extern int tcpKeepIntvl;
  117. extern int tcpMaxIdle;
  118.  
  119. /*
  120.  * A macro to force a time value to be in a certain range.
  121.  */
  122. #define    TCP_TIMER_RANGESET(tv, value, tvmin, tvmax) { \
  123.     (tv) = (value); \
  124.     if ((tv) < (tvmin)) { \
  125.         (tv) = (tvmin); \
  126.     } else if ((tv) > (tvmax)) { \
  127.         (tv) = (tvmax); \
  128.     } \
  129. }
  130. #endif /* _IPS_TCP_TIMER */
  131.